<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset=utf-8>
	<meta name=description content="">
	<meta name=viewport content="width=device-width, initial-scale=1">
	<script type="text/javascript">
	(function (designW) {
		var docEl = document.documentElement,
			resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
			recalc = function () {
				var clientWidth = docEl.clientWidth;
				if (!clientWidth) return;
				docEl.style.fontSize = 100 * (clientWidth / designW) + 'px';
			};
		if (!document.addEventListener) return;
			recalc();
		window.addEventListener(resizeEvt, recalc, false);
		document.addEventListener('DOMContentLoaded', recalc, false);
	})(750);
	</script>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body class="p-lottery1">
<div class="wrapper">
	<div class="head"></div>
	<table cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td></td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td class="lottery-btn"></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</table>
	<div class="lottery-info" style="display: none;">
		<div class="l1">恭喜您！获得<span id="prize-name"></span></div>
		<div class="l aa">
			购机券码：
			<span class="code">3762438</span>
		</div>
		<div class="l bb">
			填写资料领取奖品
		</div>
		<div class="l">快来照亮你的美吧！</div>
		<a class="go"></a>
		<a class="buy"></a>
		<a class="buy-rule"></a>
	</div>
	<div class="l-info">
		<div class="close"></div>
	</div>
<script src="jq.js"></script>
<script type="text/javascript">
	var target;
	var vivoCode;
	var loops = 0;
	var running = 0;

	$('.lottery-btn').click(function() {
		if (running == 1) {
			return;
		}
		$.ajax({
			url: 'http://vivo.ixunlu.cn/vivo/api/lottery',
			dataType: 'jsonp' ,
			jsonp: 'cb',
			success: function(data) {
				if (data.status != 1) {
					alert(data.message);
				}
				target = data.data.type;
				vivoCode = data.data.vivoCode;

				// target = 4;
			}
		});
		running = 1;
		var loopOrder = [
			{
				name: 'VIVO商城抵用券5元',
				order: 0,
				prize: 3,
				type: 'b'
			},
			{
				name: 'VIVO X9手机',
				order: 1,
				prize: 1,
				type: 'a'
			},
			{
				name: 'VIVO商城购机券100元',
				order: 2,
				prize: 2,
				type: 'b'
			},
			{
				name: 'XE600耳机',
				order: 5,
				prize: 4,
				type: 'a'
			},
			{
				name: 'VIVO商城抵用券5元',
				order: 8,
				prize: 3,
				type: 'b'
			},
			{
				name: 'VIVO商城购机券100元',
				order: 7,
				prize: 2,
				type: 'b'
			},
			{
				name: 'VIVO商城抵用券5元',
				order: 6,
				prize: 3,
				type: 'b'
			},
			{
				name: 'VIVO自拍杆',
				order: 3,
				prize: 5,
				type: 'a'
			}
		]
		// var loopOrder = [0,1,2,5,8,7,6,3];
		var i = 0;
		var loop = setInterval(function() {
			i = i % loopOrder.length;
			if (i == loopOrder[i].order) {
				loops++;
			}
			$('td').removeClass('active');
			$('td').eq(loopOrder[i].order).addClass('active');
			if (loops > 10 && target === loopOrder[i].prize) {
				clearInterval(loop);
				loops = 0;
				$('.lottery-info').show().addClass(loopOrder[i].type).find('#prize-name').text(loopOrder[i].name);
				$('.code').text(vivoCode);
			}
			i++;
		}, 100);
	});
	$('.close').click(function() {
		$('.l-info').fadeOut();
	});
	$('.buy-rule').click(function() {
		$('.l-info').fadeIn();
	});
</script>
</div>
</body>
</html>